import request from '../../../utils/request'
import { TrademarksResponse, Trades } from './type'

enum API {
  GETTRADEMARK_URL = '/admin/product/baseTrademark',
  ADDTRADESMARK_URL = '/admin/product/baseTrademark/save',
  UPDTRADESMARK_URL = '/admin/product/baseTrademark/update',
  DELETETRADESMARK_URL = '/admin/product/baseTrademark/remove',
}

export const reqTrademark = (page: number, limit: number) =>
  request.get<TrademarksResponse>(`${API.GETTRADEMARK_URL}/${page}/${limit}`)

export const reqAddOrUpdateTrades = (data: Trades) => {
  if (data.id) {
    return request.put<any, any>(API.UPDTRADESMARK_URL, data)
  } else {
    return request.post<any, any>(API.ADDTRADESMARK_URL, data)
  }
}

export const reqDeleteTrade = (id: number) =>
  request.delete<any>(`${API.DELETETRADESMARK_URL}/${id}`)
